package org.jetlinks.pro.clickhouse.engine;

import lombok.AllArgsConstructor;

@AllArgsConstructor
public enum PartitionInterval {
    days("toDate"),
    months("toYYYYMM") {
        @Override
        public String create(String arg) {
            return "toYYYYMM(fromUnixTimestamp(" + arg + "),'%Y%m')";
        }
    },
    hours("formatDateTime") {
        @Override
        public String create(String arg) {
            return "formatDateTime(fromUnixTimestamp(" + arg + "),'%Y%m%d%H')";
        }
    };

    private final String function;

    public String create(String arg) {
        return function + "(" + arg + ")";
    }
}
